<template>
  <div class="lite-flow-editor-layout">
    <div class="lite-flow-editor-sidebar">
      <component :is="SideBar" />
    </div>
    <div class="lite-flow-editor-content">
      <div class="lite-flow-editor-toolbar">
        <component :is="ToolBar" />
        <div class="lite-flow-editor-widgets">
          <component
            v-for="(Widget, index) in widgets"
            :key="index"
            :is="Widget"
          />
        </div>
      </div>
      <div class="lite-flow-editor-main">
        <slot></slot>
      </div>
    </div>
    <div class="lite-flow-editor-settingbar">
      <component :is="SettingBar" />
    </div>
  </div>
</template>

<script lang="ts" setup>
import { Graph } from '@antv/x6'
import { provide } from 'vue'
import { GraphKey, createGraphContext } from '../context/GraphContext'

interface Props {
  flowGraph: Graph | null
  SideBar: any
  ToolBar: any
  SettingBar: any
  widgets?: any[]
}

const props = defineProps<Props>()

// 提供 graph context
provide(GraphKey, createGraphContext())
</script>

<style lang="scss" scoped>
.lite-flow-editor-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.lite-flow-editor-sidebar {
  width: 280px;
  border-right: 1px solid #d9d9d9;
}

.lite-flow-editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.lite-flow-editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid #d9d9d9;
}

.lite-flow-editor-widgets {
  display: flex;
  align-items: center;
}

.lite-flow-editor-main {
  flex: 1;
  position: relative;
}

.lite-flow-editor-settingbar {
  width: 300px;
  border-left: 1px solid #d9d9d9;
}
</style> 